<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>去中心化聊天室</title>
    <style>
      body {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
        margin: 0;
        padding: 20px;
        background-color: #f5f5f5;
      }
      #app {
        max-width: 800px;
        margin: 0 auto;
        background-color: #fff;
        border-radius: 8px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        padding: 20px;
      }
      h1 {
        text-align: center;
        color: #333;
      }
      #chat-container {
        display: none;
      }
      #room-controls {
        margin-bottom: 20px;
      }
      #messages {
        height: 400px;
        overflow-y: auto;
        border: 1px solid #ddd;
        padding: 10px;
        margin-bottom: 10px;
        border-radius: 4px;
        background-color: #fafafa;
      }
      .message {
        margin-bottom: 10px;
        padding: 8px;
        border-radius: 4px;
      }
      .message.sent {
        background-color: #dcf8c6;
        text-align: right;
        margin-left: 20%;
      }
      .message.received {
        background-color: #fff;
        text-align: left;
        margin-right: 20%;
      }
      #input-container {
        display: flex;
        gap: 10px;
      }
      #message-input {
        flex: 1;
        padding: 10px;
        border: 1px solid #ddd;
        border-radius: 4px;
      }
      button {
        padding: 10px 20px;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        background-color: #007bff;
        color: white;
      }
      button:hover {
        background-color: #0056b3;
      }
      #status {
        text-align: center;
        color: #666;
        margin-top: 10px;
        font-size: 0.9em;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <h1>去中心化聊天室</h1>
      <div id="room-controls">
        <input type="text" id="room-name-input" placeholder="输入聊天室名称" />
        <button id="join-room-button">加入聊天室</button>
      </div>
      <div id="chat-container">
        <div id="messages"></div>
        <div id="input-container">
          <input type="text" id="message-input" placeholder="输入消息..." />
          <button id="send-button">发送</button>
        </div>
      </div>
      <div id="status">
        <p>正在初始化 P2P 节点...</p>
      </div>
    </div>
    <script type="module" src="/src/main.ts"></script>
  </body>
</html>